package com.codingfuture.erp_system.service.impl;

import com.codingfuture.erp_system.entity.Role;
import com.codingfuture.erp_system.mapper.RoleManageMapper;
import com.codingfuture.erp_system.service.RoleManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleManageServiceImpl implements RoleManageService {

    @Autowired
    private RoleManageMapper roleManageMapper;

    @Override
    public List<Role> findByAll(String name) {
        return roleManageMapper.findByAll(name);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean insert(String name) {
        return roleManageMapper.insert(name) != 0;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean update(String name, Integer id) {
        return roleManageMapper.update(name, id) != 0;
    }

    @Override
    public Role findById(int id) {
        return roleManageMapper.findById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean delete(int id) {
        return roleManageMapper.delete(id) != 0;
    }
}
